package com.simu.towercrane.fragments;

import java.util.ArrayList;
import java.util.List;

import com.simu.towercrane.R;
import com.simu.towercrane.adapter.GlassespagerAdapter;

import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.webkit.WebView.FindListener;
import android.widget.ImageView;
import android.widget.TextView;

public class ProductFragment extends BaseFragment {

	private ViewPager viewPager;
	private GlassespagerAdapter myGlassespagerAdapter;

	private TextView productSurveyTX;
	private TextView imageanddettilsTX;
	private ImageView imageViewBack;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		return inflater.inflate(R.layout.fragment_product, container, false);
	}

	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
		// TODO Auto-generated method stub
		productSurveyTX = (TextView) getView().findViewById(R.id.productsurvey);
		imageanddettilsTX = (TextView) getView().findViewById(R.id.imageanddettils);
		imageViewBack = (ImageView) getView().findViewById(R.id.product_back_IV);
		ProductSurveyFragment one = new ProductSurveyFragment();
		ImageandDettilsFragment two = new ImageandDettilsFragment();

		ArrayList<Fragment> lists = new ArrayList<Fragment>();
		lists.add(one);
		lists.add(two);
		myGlassespagerAdapter = new GlassespagerAdapter(getFragmentManager(),
				lists);

		viewPager = (ViewPager) getView().findViewById(R.id.viewPager);
		viewPager.setAdapter(myGlassespagerAdapter);
		
		imageViewBack.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				getActivity().finish();
			}
		});
		
		productSurveyTX.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View arg0) {
				productSurveyTX.setTextColor(getResources().getColor(
						R.color.top_bar_normal_bg));
				// TODO Auto-generated method stub
				imageanddettilsTX.setTextColor(getResources().getColor(
						R.color.normal_text_color));
				viewPager.setCurrentItem(0);
			}
		});
		imageanddettilsTX.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				imageanddettilsTX.setTextColor(getResources().getColor(
						R.color.top_bar_normal_bg));
				// TODO Auto-generated method stub
				productSurveyTX.setTextColor(getResources().getColor(
						R.color.normal_text_color));
				viewPager.setCurrentItem(1);
			}
		});

		viewPager.setOnPageChangeListener(new OnPageChangeListener() {

			@Override
			public void onPageSelected(int arg0) {
				// TODO Auto-generated method stub
				switch (arg0) {
				case 0:
					productSurveyTX.setTextColor(getResources().getColor(
							R.color.top_bar_normal_bg));
					imageanddettilsTX.setTextColor(getResources().getColor(
							R.color.normal_text_color));
					break;
				case 1:
					imageanddettilsTX.setTextColor(getResources().getColor(
							R.color.top_bar_normal_bg));

					productSurveyTX.setTextColor(getResources().getColor(
							R.color.normal_text_color));
					break;

				}

			}

			@Override
			public void onPageScrolled(int arg0, float arg1, int arg2) {
				// TODO Auto-generated method stub

			}

			@Override
			public void onPageScrollStateChanged(int arg0) {
				// TODO Auto-generated method stub

			}
		});

	}

	
	

}
